<template>
  <el-dialog draggable overflow :title="'盘点审核'" v-model="visible" :width="1024" destroy-on-close
    @closed="$emit('closed')">
    <sk-upload v-model="form.attachments" :limit="10" :disabled="true" tip="">
    </sk-upload>
    <el-row align="bottom">
      <el-col :span="7" align="bottom">
        <el-form-item label="单据日期" prop="billdate">
          <el-date-picker v-model="form.billdate" type="date" placeholder="选择日期" format="YYYY-MM-DD"
            value-format="YYYY-MM-DD" />
          <!-- <el-input label="单据日期" v-model="form.code" clearable></el-input> -->
        </el-form-item>
      </el-col>
      <el-col :span="7" align="bottom">
        <el-form-item label="编号" prop="code">
          <el-input label="编号" v-model="form.code" disabled></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="10">
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" disabled></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="财务备注" prop="financeremark">
          <el-input v-model="form.financeremark"></el-input>
        </el-form-item>
      </el-col>
    </el-row>
    <sc-VxeTable ref="save" :gridOps="gridOps" :data="form.details" :tablecode="'storage_action_inventory_save_finance'">
    </sc-VxeTable>
    <template #footer>
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" :loading="isSaveing" @click="submit()">审 核</el-button>
    </template>
  </el-dialog>
</template>

<script>

export default {
  emits: ["success", "closed"],
  components: {},
  data() {
    return {
      gridOps: {
        height: 300,
      },
      form: {
        id: "",
        details: [],
        attachments: [],
      },
      visible: false,
      isSaveing: false,
    };
  },
  mounted() { },
  methods: {
    //显示
    open() {
      this.visible = true;
      return this;
    },
    //表单提交方法
    submit() {
      this.isSaveing = true;
      this.$API.storage.inventory.faudit.post({ id: this.form.id, financeremark: this.form.financeremark }).then((res) => {
        if (res.code == 200) {
          this.$emit("success", this.form);
          this.visible = false;
          this.$message.success("操作成功");
        }
      }).finally(() => {

        this.isSaveing = false;
      });
    },
    getItems(id, itemid) {
      this.$API.storage.inventory.info.get({
        filter: [{ id: id }],
      }).then((res) => {
        if (res.code == 200) {
          this.form = res.data;
          console.log(itemid);
          this.form.id = itemid;
        }
      });

    },
    //表单注入数据
    setData(data, id) {
      this.getItems(data.id, id);
    },
  },
};
</script>

<style></style>
